package com.chm.fw.utils;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * sp类具体存储文件的方法
 * Created by chenmin on 2018/7/16.
 */

public class SPUtils {

    public static String getCookie(Context context) {
        if (context == null) {
            return "";
        }
        SharedPreferences sp = context.getSharedPreferences("Session", Context.MODE_PRIVATE);
        return sp.getString("Cookie", "");
    }

    public static void setCookie(Context context, String cookie) {
        if (context == null) {
            return;
        }
        SharedPreferences sp = context.getSharedPreferences("Session", Context.MODE_PRIVATE);
        sp.edit().putString("Cookie", cookie).apply();
    }

    public static String getLoginToken(Context context) {
        if (context == null) {
            return "";
        }
        SharedPreferences sp = context.getSharedPreferences("Login", Context.MODE_PRIVATE);
        return sp.getString("Token", "");
    }

    public static void setLoginToken(Context context, String loginToken) {
        if (context == null) {
            return;
        }
        SharedPreferences sp = context.getSharedPreferences("Login", Context.MODE_PRIVATE);
        sp.edit().putString("Token", loginToken).apply();
    }
}
